var xc_sys_config = require('xc/sys/config.js');
var toolv2 = require('xc/sys/toolv2.js');
import Notify from '/vant/weapp/notify/notify.js';
// var Notify = require('/vant/weapp/notify/notify.js');

var util = require('we7/resource/js/util.js');
require('xc/sys/mixins.js')
App({
  locationChangeFn: function (ev) {

  },
  startLocation: function () {
    // wx.onLocationChange(locationChangeFn)
    // wx.startLocationUpdateBackground({

    //   complete(erx){




    //   }
    // })
  },

  onLaunch: function () {
    // Notify('666666');


    setTimeout(function () {
      wx.loadFontFace({
        global: true,
        family: "vant-icon",
        source: 'url("https://img01.yzcdn.cn/vant/vant-icon-f463a9.ttf")',
        success(res) {

          // self.setData({ loaded: true })
        },
        fail: function (res) {

        },
        complete: function (res) {

        }
      });
    }, 100)



    wx.getSystemInfo({
      success: e => {

        this.globalData.sysinfo = e
        this.globalData.StatusBar = e.statusBarHeight;
        let capsule = wx.getMenuButtonBoundingClientRect();


        this.globalData.capsulespacing = e.windowWidth - capsule.right
        this.globalData.capsulewidth = capsule.width


        if (capsule) {
          this.globalData.Custom = capsule;

          this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;


          // this.globalData.CustomBar = capsule.height + (capsule.top - e.statusBarHeight ) * 2  ;

          //2为手机调整没有用
          this.globalData.conttop = capsule.bottom + (e.statusBarHeight - (capsule.bottom - capsule.top)) / 2


        } else {
          this.globalData.CustomBar = e.statusBarHeight + 44;
          this.globalData.conttop = e.statusBarHeight + 43;
        }
      }
    })
    return;
    // 展示本地存储能力
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
    // 获取用户信息
    wx.getSetting({
      success: res => {
        if (res.authSetting['scope.userInfo']) {
          // 已经授权，可以直接调用 getUserInfo 获取头像昵称，不会弹框
          wx.getUserInfo({
            success: res => {
              // 可以将 res 发送给后台解码出 unionId
              this.globalData.userInfo = res.userInfo

              // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
              // 所以此处加入 callback 以防止这种情况
              if (this.userInfoReadyCallback) {
                this.userInfoReadyCallback(res)
              }
            }
          })
        }
      }
    })
  },
  globalData: {

    userlocation: {
      location: {
        code: "none", //none 未尝试，ok:可以使用  ing:开启中  fail 失败    deny 拒绝 
        lasttime: 0,
        latitude: 0,
        longitude: 0,
        speed: 0,
        accuracy: 0,
        altitude: 0,
        verticalAccuracy: 0,
        horizontalAccuracy: 0

      },
      lastaddr: {
        lasttime: 0
      },
      actaddr: {},

    },
    sysdata: {},
    actleadgroup: null, //当前选择团长管理端
    leadgroups: [], //跟我有关的所有团，开发中
    islogin: false,
    isreg: false,
    userInfo: null,
    member: null,
    temcart: {},
    depcart: {},
    temurl: "",
    userset: { //自提有关信息，
      pickuptime: null,
      name: "",
      phone: ""
    },
    footnav: {
      club: null, //底部导航
    },
    clubinfo: null, //我所属的团长
    // themconfig:{},
    // mamageclub:{
    //   leadgroups:null, //我能管理的团队
    //   actleadgroup:null, //当前操作的团队
    //   islogin:false,
    //   userinfo:null
    // }, 
    share: {
      shareid: 0, //分享用户id
      taskid: 0, //帮助用户id
    },
    clientcache: {

    },
    basicurl: "-1",
    integralname: "积分"



  },
  util: util,
  toolv2: toolv2,
  vent: {
    Notify: Notify
  },
  xc_sys_config: xc_sys_config,
  //导航菜单，微擎将会自己实现一个导航菜单，结构与小程序导航菜单相同
  //用户信息，sessionid是用户是否登录的凭证
  userInfo: {
    sessionid: null,
  },
  "tabBar": {
    "color": "#999",
    "selectedColor": "#f86b4f",
    "borderStyle": "#fff",
    "backgroundColor": "#fff",
    "list": [{
        "pagePath": "/xc_mall/pages/store/index",
        "iconPath": "/xc_mall/resource/icon/home.png",
        "selectedIconPath": "/xc_mall/resource/icon/home-selected.png",
        "text": "首页"
      },
      {
        "pagePath": "/xc_mall/pages/category/category",
        "iconPath": "/xc_mall/resource/icon/category.png",
        "selectedIconPath": "/xc_mall/resource/icon/category-selected.png",
        "text": "分类"
      },
      {
        "pagePath": "/xc_mall/pages/home/index",
        "iconPath": "/xc_mall/resource/icon/user.png",
        "selectedIconPath": "/xc_mall/resource/icon/user-selected.png",
        "text": "我的"
      }
    ]
  },
  siteInfo: require('siteinfo.js')
})